

# 数据准备
methods = ['MF', 'LightGCN', 'IPS', 'CausE', 'DICE', 'MACR', 'Ours']
ndcg = [0.312, 0.327, 0.302, 0.315, 0.323, 0.295, 0.331]
efi = [0.521, 0.498, 0.603, 0.587, 0.562, 0.718, 0.684]

# 创建专业图表
plt.figure(figsize=(6,3), dpi=600)
# plt.grid(True, linestyle='--', alpha=0.7)
plt.scatter(ndcg, efi, s=100, c='#1f77b4', edgecolors='black', zorder=5)

# 添加方法标签和趋势线
for i, method in enumerate(methods):
    plt.annotate(method, (ndcg[i], efi[i]), 
                 xytext=(5, -5), textcoords='offset points',
                 fontsize=8, weight='normal' if method == 'Ours' else 'normal',
                 color='#d62728' if method == 'Ours' else 'black')

# 添加趋势线（二次多项式拟合）
z = np.polyfit(ndcg, efi, 2)
p = np.poly1d(z)
x_lin = np.linspace(min(ndcg)-0.01, max(ndcg)+0.01, 100)
plt.plot(x_lin, p(x_lin), 'r--', linewidth=1.5, alpha=0.7)

# 设置坐标轴和标题
plt.xlabel('NDCG@10', fontsize=12, fontweight='bold')
plt.ylabel('Exposure Fairness Index (EFI)', fontsize=12, fontweight='bold')
# plt.title('Accuracy-Fairness Trade-off on KuaiRec Dataset', 
#           fontsize=14, fontweight='bold', pad=15)

# 添加专业元素
# plt.text(0.297, 0.73, 'High Fairness\nLow Accuracy', 
#          fontsize=10, color='#2ca02c', ha='center')
# plt.text(0.332, 0.48, 'High Accuracy\nLow Fairness', 
#          fontsize=10, color='#d62728', ha='center')
plt.axvline(x=np.mean(ndcg), color='gray', linestyle=':', alpha=0.5)
plt.axhline(y=np.mean(efi), color='gray', linestyle=':', alpha=0.5)

# 优化布局
plt.xlim(0.29, 0.34)
plt.ylim(0.48, 0.74)
plt.tight_layout()

# 保存高质量图片
plt.savefig('accuracy_fairness_tradeoff.png', bbox_inches='tight', dpi=600)
plt.show()
